import { registerMicroApps, start,setDefaultMountApp } from 'qiankun';
import microApps from './apps.js'
import './style.css'


const goto = (path) => {
  console.log(1);
  history.pushState(null, path, path)
};



document.querySelector('#container').innerHTML = `
  <h1>Hello Vite!</h1>
  <button id="index">index</button>
  <button id="jx">jx</button>
`


document.getElementById('index').addEventListener('click',function(){
    goto('/index')
})

document.getElementById('jx').addEventListener('click',function(){
  goto('/jx')
})


const apps = microApps.map((item) => ({
  ...item,
}));

registerMicroApps(apps, {
  beforeLoad: (app) => console.log('before load app.name====>>>>>', app.name),
  beforeMount: [
    (app) => console.log('[LifeCycle] before mount %c%s', 'color: green;', app.name),
  ],
  afterMount: [
    (app) => console.log('[LifeCycle] after mount %c%s', 'color: green;', app.name),
  ],
  afterUnmount: [
    (app) => console.log('[LifeCycle] after unmount %c%s', 'color: green;', app.name),
  ],
});


registerMicroApps([
  {
    name: 'index',
    entry: '//localhost:9527',
    container: '#subapp-viewport',
    activeRule: '/index',
  }
]);
// 启动 qiankun
// setDefaultMountApp('/index');
start();
